<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Serenity
 * Date: 24-6-11
 * Time: 12:09
 * To change this template use File | Settings | File Templates.
 */


define("ADMINSTRATOR", 3);
define("ONDERHOUD", 2);
define("MEDEWERKER", 1);
define("ALL", 0);
class Menu
{

    private static $menu = array();
    private $title;
    private $menuItems = array();

    public function __construct($title)
    {
        $this->title = $title;
    }

    public static function create($title)
    {
        $menu = new Menu($title);
        self::$menu[] = $menu;
        return $menu;
    }

    public function add(MenuItem $item)
    {
        $this->menuItems[] = $item;
        return $this;
    }

    public function getItems()
    {
        $list = array();
        foreach ($this->menuItems as $item)
            $list[] = $item->toArray();
        return $list;
    }

    public static function getMenu()
    {
        return self::$menu;
    }

    public function setTitle($title)
    {
        $this->title = $title;
    }

    public function getTitle()
    {
        return $this->title;
    }

    public static function getsub()
    {
        $sub = array();
        $sub[] = array('title' => UrlDecoder::get_Controller_Name(), 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), null));
        $sub[] = array('title' => 'Overzicht', 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), 'overzicht'));
        $sub[] = array('title' => 'Toevoegen', 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), 'toevoegen'));
        switch (UrlDecoder::get_Controller_Name()) {
            case 'Probleem':
                $sub[] = array('title' => 'Openstaande problemen', 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), 'overzichtOpenstaand'));
                $sub[] = array('title' => 'Mogelijke problemen', 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), 'overzichtMogelijk'));
                break;
            //openstaand,mogelijk
            case 'Incident':
                $sub[] = array('title' => 'Openstaande incidenten', 'url' => SDS::getURL(UrlDecoder::get_Controller_Name(), 'overzichtOpenstaand'));
                //openstaand
                break;
            case 'login':
            case 'script':
                $sub = array();
           break;


        }
        return $sub;
    }

}

class MenuItem
{

    private $id;
    private $link;


    public static function create($id, $link)
    {
        return new MenuItem($id, $link);
    }

    public function __construct($id, $link)
    {
        $this->id = $id;
        $this->link = $link;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getId()
    {

        return $this->id;
    }

    public function setLink($link)
    {
        $this->link = $link;
    }

    public function getLink()
    {
        return $this->link;
    }

    public function toArray()
    {
        return array('title' => $this->id, 'link' => $this->link);
    }

}


